/*
 * PsMediaCaster.h
 *
 *  Created on: 2016年8月24日
 *      Author: zhengboyuan
 */

#ifndef PSMEDIACASTER_H_
#define PSMEDIACASTER_H_

#include "MediaStream.h"
#include "PsCaster.h"


namespace av
{


class PsMediaCaster
{
public:
    PsMediaCaster():
        m_eventCb(),
        m_eventContext()
    {
    }

	virtual ~PsMediaCaster() {}

	virtual int open(const std::string& ip, uint16_t port, const MediaFormat& fmt) =0;

	virtual void close() =0;

	virtual bool isOpen() =0;

	virtual void setID(int id) =0;

	virtual int getID() =0;

	virtual bool addTarget(const std::string& ip, uint16_t port) =0;

	virtual void removeTarget(const std::string& ip, uint16_t port) =0;

	virtual size_t getTargetCount() =0;

	virtual void removeAllTarget() =0;
	
	virtual bool write(av::MediaPacketPtr& pkt) =0;

    virtual void setEventCallback(PsCasterEventCallback cb, void* context)
    {
        m_eventCb = cb;
        m_eventContext = context;
    }

protected:

    void fireCasterEvent(const PsCasterEvent& event)
    {
        if (m_eventCb)
        {
            (*m_eventCb)(&event, m_eventContext);
        }
    }

protected:
    PsCasterEventCallback   m_eventCb;
    void* m_eventContext;

};


class RtpPsMediaCaster : public PsMediaCaster
{
public:
	virtual ~RtpPsMediaCaster() {}

	virtual void setPayload(uint8_t payload) = 0;

	virtual void setSsrc(uint32_t ssrc) = 0;

};


} /* namespace av */

#endif /* TSMEDIACASTER_H_ */
